package org.megha.blog.example.enums;

/**
 * Lists all payment modes and their surcharges.
 *
 * @author megha birmiwal
 */
public class PaymentModeLister {

	public static void main(String[] args) {
		// .values() returns an array of all possible values
		PaymentMode[] values = PaymentMode.values();
		for (PaymentMode pm : PaymentMode.values()) {
			System.out.println(pm.name() + " / " + pm.getSurcharge());
		}

		// go from string to the corresponding enum
		PaymentMode pm = PaymentMode.valueOf("PAYPAL");
		System.out.println(pm == PaymentMode.PAYPAL);

		// throws exception because there is no enum value called XYZ
		PaymentMode mode = PaymentMode.valueOf("XYZ");
	}
}
